<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<button onclick="graphQLFetcher()">发送</button>
	<script>
		var id = 2;
		var params = `{
			  hello
			  account {
			    name
			    age
			  }
			  getStudents(id:${id})
			}`,
			query = `
				query Query($id: Int!){
					getStudents(id: $id)
				}
			`,
			variables = {
				id: 3
			},
			obj = {
				query,
				variables
			}
		function graphQLFetcher(graphQLParams=obj) {
	      return fetch('/graphql', {
	        method: 'post',
	        headers: {
	          'Accept': 'application/json',
	          'Content-Type': 'application/json'
	        },
	        body: JSON.stringify(graphQLParams),
	        credentials: 'include',
	      }).then(function (response) {
	        return response.json();
	      });
	    }
	</script>
</body>
</html>